
************************************************************************************************************************************************
****************************** REPLICATION CODE: RELIGION AND BRAZILIAN POLITICS 
****************************** 2019. Cambridge University Press
****************************** By Amy Erica Smith (amyericas@gmail.com) 



***************************** CHAPTER 9, FIGURE 27. COMPARISON OF POSITIONS OF POLITICIANS, CITIZENS, AND CLERGY
tempfile tf_abortion tf_gay tf_social tf_racism tf_enviro tf_deps tf_citizens tf_clergy
********* Group 1. clergy
*target vars: p24_discuss_abortion p23_discuss_homosexuality p19_ministerpoor p26_discuss_racism p25_discuss_environment 	
use "C:\Users\aesmith2\Dropbox\Work\Data\2014 field work Brazil and US\Data\Clergy survey\ClergySurvey_BRUS.dta", clear
drop if country == 2
	sencode city, replace
	g juiz = city == 2
	g conference = city == 1
g idnum = city*10000+qnrnum1
g evanpent = (p1_denomination > 1)
forvalues i = 8/27 {
	replace p`i'_ = (p`i'_-1)/4
}
rename p24_ abortion
	replace abortion = 1-abortion
rename p23_ gay
	replace gay = 1-gay
rename p19_ social
rename p26_ racism
rename p25_ enviro
global results ""
foreach var in abortion gay social racism enviro {
	egen mn_`var' = mean(`var') if evanpent == 0
	egen sd_`var' = sd(`var') if evanpent == 0
	egen mnmn_`var' = mean(mn_`var'), by(abortion)
	egen mnsd_`var' = mean(sd_`var'), by(abortion)
	replace `var' = (`var'-mnmn_`var')/mnsd_`var'
	drop mn_* sd_* mnmn_* mnsd_*
	mean `var', over(evanpent)
	parmest, saving(`tf_`var'', replace) level(90) flist(results)
}
dsconcat $results
g group = 1
save `tf_clergy', replace


********* Group 2. citizens
*target vars: abortion d6r ros rac2 env1 
use "C:\Users\aesmith2\Dropbox\Work\Data\LAPOP\Individual country datasets\Brazil\brazil_lapop_dims final 2007 v5.dta", clear
foreach var of varlist * {
	local new = lower("`var'") 
	rename `var' `new' 
}
recode year 2006=2007
append using "C:\Users\aesmith2\Dropbox\Work\Data\LAPOP\Individual country datasets\Brazil\brazil_lapop_dims_2008_final_data_set_v10.dta", force
append using "C:\Users\aesmith2\Dropbox\Work\Data\LAPOP\Individual country datasets\Brazil\Brazil lapop_2010.dta", force
	replace year = 2010 if year == .
	replace wt = 1 if year == 2008 | year == 2010
append using "C:\Users\aesmith2\Dropbox\Work\Data\LAPOP\Individual country datasets\Brazil\54861031Brazil LAPOP AmericasBarometer 2012 Rev1_W.dta", force
append using "C:\Users\aesmith2\Dropbox\Work\Data\LAPOP\Individual country datasets\Brazil\523605379Brazil LAPOP AmericasBarometer 2014 v1_W.dta", force
replace year = 2014 if year == .
append using "C:\Users\aesmith2\Dropbox\Work\Data\LAPOP\Individual country datasets\Brazil\dirty_GM v07172017_Brazil 2017 only.dta", force
replace year = 2017 if year == .
lab lang en
summ year
recode q5a q5b ing4 b1 b2 b3 b4 b6 e5 e11 e15 d1 d2 d3 d4 d5 d6 ed q2 q3 q3c vs18 vs19 ///
	r4 r5 r6 r7 r15 r18 r16 vb10 rac2 (88 98 988 =.)
recode q3c (1=1) (2 5 =2) (4 11 = 3) (6 12 3 7 77 1501 = 4) if year >= 2012 , g(rel)
	replace rel = vs18 if year == 2007
	recode rel (8 = 1) (2 3 = 2) (12 13 = 3) (1 4 5 6 7 9 10 11 = 4) if year == 2007
	replace rel = q3 if year == 2008
	recode rel (1=1) (2 5 = 2) (13 4 = 3) (3 6 7 10 11 = 4) if year == 2008
	replace rel = q3c if year == 2010
	recode rel (1 = 1) (2 5 = 2) (4 11 = 3) (3 6 7 8 10 12 = 4) if year == 2010
drop if rel > 2
recode rel (2=1)(1 3 4 = 0), g(evangelical)
************ POLICY ISSUES
g d6r= (d6-1)/9
	lab var d6r "Support for Gay Marriage"
recode w14a (2=0), g(abortion)
	lab var abortion "Abortion Justified for Mother's Health"
capture drop ros*r
forvalues i = 1/6 {
	recode ros`i' (88 98 = .)
	g ros`i'r = (ros`i'-1)/6
} 
egen ros = rowmean(ros2r ros3r ros4r ros6r)
recode env1 (3=.5) (2=0) (1=1)
	replace env1 = (env1c-1)/6 if year == 2017
	recode env1 (0/.4 = 0) (.6/1 = 1)
replace rac2 = (rac2-1)/6
rename d6r gay 
rename ros social 
rename rac2 racism 
rename env1 enviro
global results
foreach var in abortion gay social racism enviro {
	egen mn_`var' = mean(`var') if evan == 0
	egen sd_`var' = sd(`var') if evan == 0
	egen mnmn_`var' = mean(mn_`var'), by(abortion)
	egen mnsd_`var' = mean(sd_`var'), by(abortion)
	replace `var' = (`var'-mnmn_`var')/mnsd_`var'
	drop mn_* sd_* mnmn_* mnsd_*
	mean `var', over(evan)
	parmest, saving(`tf_`var'', replace) level(90) flist(results)
}
dsconcat $results
g group = 2
save `tf_citizens', replace


********* Group 3. representatives
*target vars: aborto gaymarriage socialspending cotaafro enviro
use "C:\Users\aesmith2\Dropbox\Work\Data\Brazilian Legislative Surveys\Data\BLS 7 waves.dta", clear
drop evangel
drop if religion > 2
recode aborto 9 = . 
	replace aborto = (5-aborto)/4
recode casament 9 = .
	g gaymarriage = (casament-1)/4
recode cot* (9 = .)
	replace cotrenda = (cotrenda-1)/4
	replace cotaafro = (cotaafro-1)/4
foreach var in saude edfund edsuper infra socpol {
	recode `var' (9 = .)
	replace `var' = (`var'-1)/4
}
egen socialspending = rowmean(saude edfund socpol cotrenda)
recode enviro (2=0) (9 = .)
rename aborto abortion 
rename gaymarriage gay
rename socialspending social
rename cotaafro racism
global results
foreach var in abortion gay social racism enviro {
	egen mn_`var' = mean(`var') if evan == 0
	egen sd_`var' = sd(`var') if evan == 0
	egen mnmn_`var' = mean(mn_`var'), by(abortion)
	egen mnsd_`var' = mean(sd_`var'), by(abortion)
	replace `var' = (`var'-mnmn_`var')/mnsd_`var'
	drop mn_* sd_* mnmn_* mnsd_*
	mean `var', over(evan)
	parmest, saving(`tf_`var'', replace) level(90) flist(results)
}
dsconcat $results
g group = 3
save `tf_deps', replace
********** Combine data
dsconcat `tf_clergy' `tf_citizens' `tf_deps'
rename parm evan
	drop if evan == "0"
rename eq dv
	sencode dv, replace
	lab def dv 1 "Abortion" 2 "Homosexuality/Gay Marriage" 3 "Ministry to Poor/Social Policy" 4 "Anti-Racism/Aff Action" 5 "Environmental Protection", modify
	lab val dv dv
lab def group 1 "Clergy" 2 "Citizens" 3 "Legislators"
	lab val group group
sort dv group
g xvar = _n + dv - 1
graph twoway (rspike min90 max90 xvar, lcolor(gs8)) ///
			 (scatter estimate xvar if group == 1, msymbol(+) msize(vlarge) mcolor(black) mlwidth(medthick)) ///
			 (scatter estimate xvar if group == 2, msymbol(O) mcolor(black)) ///
			 (scatter estimate xvar if group == 3, msymbol(T) mcolor(black)) , ///
	graphregion(fcolor(white) lcolor(black)) legend(order(2 "Clergy" 3 "Citizens" 4 "Legislators") col(3)) ///
	xlabel(2 "Abortion" 6 "Homosexuality/Same-Sex Marriage" 10 "Ministry to Poor/Social Spending" 14 "Anti-Racism/Aff Action" 18 "Environmental Protection", ///
				labsize(small)) xtitle("") xline(4 8 12 16, lcolor(gs15)) ///
	yline(0, lcolor(gs10)) ytitle("Evangelical Divergence from Catholic" "Positions (Standard Deviations)", margin(small)) ///
	note("Sources: Churches North and South 2014 (Clergy Study); AmericasBarometer 2007-2014; and Brazilian Legislative Studies." ///
		"Catholics and evangelicals/Pentecostals only. Catholics assigned value of 0. Means and standard deviations for standardized" ///
		"values calculated based only on Catholic respondents. Whiskers represent 90% CIs.", span size(vsmall))
***************************** END CHAPTER 9, FIGURE 27. COMPARISON OF POSITIONS OF POLITICIANS, CITIZENS, AND CLERGY

